home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir31 / in_out.zip / PHASOR.ASM < prev    next >
Assembly Source File  |  1993-01-16  |  4KB  |  76 lines

  1. ;=============================================================================
  2. ;Example:
  3. ;       TASM PHASOR.ASM
  4. ;       TLINK/T PHASOR.OBJ 
  5. ;
  6. ;If you are using the A86 assembler - 
  7. ;place a "x" between bit 0 and the letter "B"
  8. ;in each of the binary numbers below....
  9. ;
  10. ;Example: 00000011xB 
  11. ;==============================================================================
  12. code_seg                SEGMENT
  13. ASSUME          cs:code_seg, ds:code_seg, es:code_seg, ss:code_seg
  14. ORG             100h
  15. begin:
  16.         jmp     start
  17. ;----------------------------------
  18. ;William Cravener                    ;Author
  19. ;520 North Stateline Rd
  20. ;Sharon, Pa 16146
  21. ;----------------------------------
  22. message1                DB      'Press Esc to Quit', 0dh, 0ah, '$'
  23. message2                DB      'Press any other key to Play$'
  24. ;----------------------------------
  25. start                   PROC    NEAR
  26.         mov     ah, 9                   ; DOS function number to print string
  27.         mov     dx, OFFSET message1     ; the message
  28.         int     21h                     ; DOS interrupt
  29.         mov     ah, 9                   ; DOS function number to print string
  30.         mov     dx, OFFSET message2     ; the message
  31.         int     21h                     ; DOS interrupt
  32. begin2:
  33.         mov     ah, 0                   ; BIOS function wait for key press
  34.         int     16h                     ; BIOS interrupt
  35.         cmp     ah, 1                   ; Esc scan code 
  36.         jz      done                    ; do we stop ?
  37.         call    phasor                  ; no call phasor sound
  38.         jmp     begin2                  ; go see if we do it again
  39. done:
  40.         mov     ax, 4c00h               ; no exit back to DOS
  41.         int     21h                     ; DOS interrupt
  42. start                   ENDP
  43. ;-------------------------------------
  44. phasor                  PROC    NEAR    ; the above explained sound program
  45.         mov     dx, 2000                ; number of times to repeat whole routine
  46.         mov     bx, 1                   ; start the sound frequency high
  47.         mov     al, 10110110b           ; the magic number
  48.         out     43h, al                 ; to initialize the port
  49. next_frequency:
  50.         mov     ax, bx                  ; move our frequency value into AX
  51.         out     42h, al                 ; copy LSB first
  52.         mov     al, ah                  ; move MSB to AL 
  53.         out     42h, al                 ; copy MSB second
  54.         in      al, 61h                 ; must turn speaker ON 
  55.         or      al, 00000011b           ; with this binary number
  56.         out     61h, al                 ; send it
  57.         mov     cx, 100                 ; 100 repeat loops
  58. delay_loop:
  59.         loop    delay_loop              ; delay loop so we can hear sound
  60.         inc     bx                      ; incrementing the value of BX lowers
  61.                                         ; the frequency each time we repeat the
  62.                                         ; whole routine
  63.         dec     dx                      ; decrement repeat routine count
  64.         cmp     dx, 0                   ; is repeat count = to 0
  65.         jnz     next_frequency          ; if not do whole thing again
  66.         in      al, 61h                 ; its time to turn speaker Off
  67.         and     al, 11111100b           ; binary number turns speaker off
  68.         out     61h, al                 ; send it
  69.         sti                             ; re-enable hardware interrupts
  70.         ret                             ; go see if user wants to do again
  71. phasor                  ENDP
  72. ;----------------------------------
  73. code_seg                ENDS
  74.  
  75. END             begin
  76.